package com.kamistoat.meimeimall.common.dubboInterface;

import com.kamistoat.meimeimall.common.To.cartTo.CartDeleteTo;
import com.kamistoat.meimeimall.common.To.wareTo.LockOrderItemWareTo;
import com.kamistoat.meimeimall.common.utils.R;
import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;
import org.apache.dubbo.common.extension.Activate;

import java.util.List;

/**
 * Cart模块 Dubbo 接口
 */
public interface CartDubboInterface {

    /**
     * 获取用户购物车中所有的选中商品
     *
     * @return R对象 内含 "orderItemToList" - List<{@link com.kamistoat.meimeimall.common.To.orderTo.OrderItemTo}>
     */
    R getOrderCartChecked();

    /**
     * 下单成功后从用户购物车中删除这些选中项
     *
     * @param lockOrderItemWareToList 下单的商品小项
     * @return R对象
     */
    @TwoPhaseBusinessAction(name = "deleteOrderItemInCart", commitMethod = "deleteOrderItemInCartCommit", rollbackMethod = "deleteOrderItemInCartRollback")
    R deleteOrderItemInCart(BusinessActionContext businessActionContext, @BusinessActionContextParameter(paramName = "lockOrderItemWareToList") List<LockOrderItemWareTo> lockOrderItemWareToList);

    /**
     * 购物车删除打钩项。分支事务提交。
     *
     * @param businessActionContext
     * @return
     */
    boolean deleteOrderItemInCartCommit(BusinessActionContext businessActionContext);

    /**
     * 购物车删除打钩项。分支事务回滚
     *
     * @param businessActionContext
     * @return
     */
    boolean deleteOrderItemInCartRollback(BusinessActionContext businessActionContext);

    R deleteOrderItem(CartDeleteTo cartDeleteTo);
}
